package by.ins.life.simpleimpl;

import java.io.Serializable;

import by.ins.life.ILife;
import by.ins.life.ILifeInitializer;
import by.ins.life.INuclear;
import by.ins.life.ISet;
import by.ins.life.impl.Nuclear;
import by.yativem.commons.utils.matrix.IMatrix;

public class SimpleInitializer implements ILifeInitializer < Double >, Serializable {
	
	private static final long serialVersionUID = 1L;

	@Override
	public void initLife(ILife<Double> life) {
		initSet(life.getSet());
	}

	protected void initSet(ISet<Double> set) {
		IMatrix<INuclear<Double>> matrix = set.getMatrix();

		int col = matrix.getColumnsCount();
		int row = matrix.getRowsCount();
		
		for (int i = 0; i < row; i++) {
			for (int j = 0; j < col; j++) {
				if (matrix.get(i, j) == null){
					
					matrix.set(i, j,  new Nuclear() );
				}
				matrix.get(i, j).setWeight(new Double(i + j));
				matrix.get(i, j).setThreshold(new Double(i + j));
				// matrix.set(i, j, t);
			}
		}		
	}

	

	
	

}
